package org.tang.springcloudvv.user.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.tang.springcloudvv.persistence.base.mapper.UserMapper;
import org.tang.springcloudvv.persistence.base.model.User;
import org.tang.springcloudvv.persistence.base.model.UserExample;


import java.util.List;

/**
 * <p><em>Created on 2021/12/1 5:44 下午</em></p>
 * 用户服务
 * @author fuzhongtang
 * @since 1.0.1
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User getUser(String userName)
    {
        UserExample example = new UserExample();
        example.createCriteria().andUserNameEqualTo(userName);
        List<User> users = userMapper.selectByExample(example);
        if (users.size()>0)
        {
            return users.get(0);
        }
        return null;
    }

    public List<User> getUserList(String userName)
    {
        UserExample example = new UserExample();
        example.createCriteria().andUserNameEqualTo(userName);
        List<User> users = userMapper.selectByExample(example);
        return users;
    }
}
